<template>
  <template v-for="item in menuList" :key="item.index">
    <el-menu-item v-if="!item.children" :index="item.index">
      <template #title>
        <component :is="Icon" :icon="item.icon" />
        <span>{{ item.title }}</span>
      </template>
    </el-menu-item>
    <el-sub-menu v-if="item.children" :index="item.index">
      <template #title>
        <component :is="Icon" :icon="item.icon" />
        <span>{{ item.title }}</span>
      </template>
      <Menu :menuList="item.children" />
    </el-sub-menu>
  </template>
</template>

<script setup lang="ts">
import Menu from './menu.vue'
import Icon from './Icon.vue'
defineProps(['menuList'])
</script>
